#include<iostream>
#include<set>
using namespace std;
set<int>s;
int n, m;
int a[100010], b[100010];
int check(int x)
{
    int res = 0; 
        for (int i = 1; i <= n; i++)
        {
            if (b[i])
                res += (b[i] - 1) / x + 1;
        }
    if (res <= m)
        return 1;
    else
        return 0;
}
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        b[a[i]]++;
        s.insert(a[i]);
    }
    if (s.size() > m)
        printf("-1\n");
    else
    {
        int l = 1, r = n;
        while (l + 1 < r)
        {
            int mid = (l + r) / 2;
            if (check(mid))
                r = mid;
            else
                l = mid;
        }
        printf("%d\n", r);
    }
    return 0;
}
